//
//  WXPKTPTakePictureLoadingView.m
//  MexicoLoan
//
//  Created by wxp on 2025/3/1.
//

#import "WXPKTPTakePictureLoadingView.h"

@implementation WXPKTPTakePictureLoadingView

#pragma mark - lazy
- (UIView *)backView
{
    if (_backView == nil) {
        _backView = [UIView  new];
        _backView.widthHeight = XY(Ratio(137), Ratio(226));
        [GlobalMethod setRoundView:_backView color:[UIColor clearColor] numRound:(16) width:0];
        _backView.backgroundColor = [UIColor colorWithHexString:@"000000" alpha:0.8];
    }
    return  _backView;
}
- (UIActivityIndicatorView *)indicator
{
    if (_indicator == nil) {
        _indicator = [UIActivityIndicatorView  new];
        _indicator.activityIndicatorViewStyle = 1;
        // 设置缩放比例，这里设置为原来的 1.5 倍，你可以根据需要调整
        CGAffineTransform scaleTransform = CGAffineTransformMakeScale(1.5, 1.5);
        _indicator.transform = scaleTransform;
        _indicator.centerXCenterY = XY(self.backView.width/2, self.backView.height/2);
    }
    return  _indicator;
}
- (UILabel *)titleLabel
{
    if (_titleLabel == nil) {
        _titleLabel = [UILabel  new];
        _titleLabel.textColor = COLOR_WHITE;
        _titleLabel.fontNum = 12;
    }
    return  _titleLabel;
}

#pragma mark - 初始化
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        self.widthHeight = XY(SCREEN_WIDTH, SCREEN_HEIGHT);
        [self addSubView];
    }
    return self;
}

//添加subview
- (void)addSubView{
    [self addSubview:self.backView];
    self.backView.centerXCenterY = XY(SCREEN_WIDTH/2, SCREEN_HEIGHT/2);
    [self.backView addSubview:self.indicator];
    [self.backView addSubview:self.titleLabel];
    //初始化页面
    [self resetViewWithTitle:@""];
}

#pragma mark - 刷新view
- (void)resetViewWithTitle:(NSString *)titleStr{
    [self.titleLabel fitTitle:titleStr variable:0];
    [self.indicator startAnimating];
}

// 竖向显示title
- (void)resetViewWithVerticalTitle:(NSString *)titleStr{
    [self.titleLabel fitTitle:titleStr variable:0];
    self.titleLabel.transform = CGAffineTransformMakeRotation(M_PI_2);
    self.titleLabel.leftCenterY = XY(Ratio(35), self.backView.height/2);
    self.indicator.rightCenterY = XY(self.backView.width-Ratio(50), self.backView.height/2);
    
    [self.indicator startAnimating];
}


@end
